package tag.doABC2
{
	import flash.utils.ByteArray;
	
	import array.ClassArray;
	import array.InstanceArray;
	import array.MetadataArray;
	import array.MethodArray;
	import array.MethodBodyArray;
	import array.ScriptArray;
	
	import util.BytesUtil;

	public class ABCFile
	{
		public var minor_vision:int = 0;
		public var major_version:int = 0;
		public var cp:CPool = null;
		public var methodArr:MethodArray = null;
		public var metadataArr:MetadataArray = null;
		public var instanceArr:InstanceArray = null;
		public var classArr:ClassArray = null;
		public var scriptArr:ScriptArray = null;
		public var methodBodyArr:MethodBodyArray = null;
		public function ABCFile()
		{
		}
		
		public function handler(bytes:ByteArray):void
		{
			this.reset();
			minor_vision = BytesUtil.readU16(bytes);
			major_version = BytesUtil.readU16(bytes);
			trace("minor_vision = " + minor_vision);
			trace("major_version = " + major_version);
			cp.handler(bytes);
			methodArr.fill(bytes);
			metadataArr.fill(bytes);
			var count:uint = BytesUtil.readU30(bytes);
			instanceArr.fill(bytes, count);
			classArr.fill(bytes, count);
			scriptArr.fill(bytes);
			methodBodyArr.fill(bytes);
		}
		
		private function reset():void
		{
			minor_vision = 0;
			major_version = 0;
			cp = new CPool();
			methodArr = new MethodArray();
			metadataArr = new MetadataArray();
			instanceArr = new InstanceArray();
			classArr = new ClassArray();
			scriptArr = new ScriptArray();
			methodBodyArr = new MethodBodyArray();
		}
	}
}